package sample.mybatis.healthes;

import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.Status;
import org.springframework.boot.actuate.info.Info;
import org.springframework.boot.actuate.trace.Trace;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.data.repository.CrudRepository;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by whyang on 2017/06/15.
 */

@RestController
public class healthController {

    @RequestMapping(value = "/health1")
    public Health healthPG(){
        DbCountHealthIndicator dbHealth = new DbCountHealthIndicator((CrudRepository)new Object());
        return dbHealth.health();
    }

    @RequestMapping(value = "/upInfo")
    public Health upInfoPG(){
        return Health.up().withDetail("hello", "world").build();
    }

    @RequestMapping(value = "/info")
    public Info info(){
        return null;
    }

    @RequestMapping(value = "/status")
    public String statusPG(){
        return  "\n" + Health.status(Status.UP).build()
                +
                "\n" + Health.status(Status.UNKNOWN).build()
                +
                "\n" + Health.status(Status.DOWN).build()
                +
                "\n" + Health.status(Status.OUT_OF_SERVICE).build();
    }

    @RequestMapping(value = "/down")
    public Health downPG(){
        return Health.down().withDetail("", "").build();
    }

    @RequestMapping(value = "/autoCfg")
    public String autoCfgPG(){
        return AutoConfigureOrder.class.toString();
    }

    @RequestMapping(value = "/trace")
    public String tracePG(){
        return Trace.class.toString();
    }


}
